package com.auxgroup.hr.front.service.personnal.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import com.auxgroup.hr.front.dao.domain.PsEthnicGrpTbl;
import com.auxgroup.hr.front.dao.repository.PsEthnicGrpTblRepository;
import com.auxgroup.hr.front.service.personnal.EthnicGrpTblService;

/** 
 * @author wangchangyun
 * @version 创建时间：180527 
 * 社保公积金service
 */
@Service("ethnicGrpTblService")
public class EthnicGrpTblServiceImpl implements EthnicGrpTblService {
	private static final Logger logger = LoggerFactory.getLogger(EthnicGrpTblServiceImpl.class);
	
	@Autowired
	private PsEthnicGrpTblRepository PsEthnicGrpTblRepository;


	@Override
	@Cacheable(value="ETHNICGRP_VALUE",key="#ethnicGrpCd")
	public PsEthnicGrpTbl getEthnicGrpTbl(String ethnicGrpCd) {
		PsEthnicGrpTbl EthnicGrpTbl = new PsEthnicGrpTbl();
		EthnicGrpTbl.setSetid("CHN");
		EthnicGrpTbl.setEffStatus("A");
		EthnicGrpTbl.setEthnicGrpCd(ethnicGrpCd);
		List<PsEthnicGrpTbl> ethnics = PsEthnicGrpTblRepository.findAll(Example.of(EthnicGrpTbl));
		if(ethnics!=null&&!ethnics.isEmpty()){
			return ethnics.get(0);
		}
		return null;
	}
	
	@Override
	@Cacheable(value="ETHNICGRP_LIST")
	public List<PsEthnicGrpTbl> getAll() {
		PsEthnicGrpTbl EthnicGrpTbl = new PsEthnicGrpTbl();
		EthnicGrpTbl.setSetid("CHN");
		EthnicGrpTbl.setEffStatus("A");
		logger.info("getAll EthnicGrpTbl param={}",EthnicGrpTbl);
		return PsEthnicGrpTblRepository.findAll(Example.of(EthnicGrpTbl));
	}


	
	
	
}
